package org.example.controller;

import org.apache.dubbo.config.annotation.Reference;
import org.example.pojo.User;
import org.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 船长
 * @create: 2024-09-03 22:53
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    // 本地注入
//    @Autowired
//    private UserService userService;

    /**
     * 1. 从zookeeper注册中心获取userService访问url
     * 2. 进行远程调用RPC
     * 3. 将结果封装为一个代理对象，给变量赋值
     */
    // 远程注入
    private UserService userService;

    @RequestMapping(value = "/sayhello",method = RequestMethod.GET)
    public String sayHello(){
        return userService.sayHello();
    }

    @RequestMapping("find")
    public User find(Integer id){
        return userService.findUserById(id);
    }
}
